package simpleFactory;
/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-07-23 14:46
 * @notify 园丁
 * @version 1.0
 */

public class FruitGardener {

    public static Fruit factory(String which)throws BadFruitException{
        //equalsIgnoreCase 忽视大小写
        if(which.equalsIgnoreCase("apple")){
            return  new Apple();
        }else if(which.equalsIgnoreCase("strawberry")){
            return new Strawberry();
        }else if(which.equalsIgnoreCase("grape")){
            return new Grape();
        }else {
            throw new BadFruitException("Bad fruit request");
        }
    }
}
